import netifaces

keymap = {
    'KEY_0': u'0',
    'KEY_1': u'1',
    'KEY_2': u'2',
    'KEY_3': u'3',
    'KEY_4': u'4',
    'KEY_5': u'5',
    'KEY_6': u'6',
    'KEY_7': u'7',
    'KEY_8': u'8',
    'KEY_9': u'9',
    'KEY_A': u'A',
    'KEY_B': u'B',
    'KEY_C': u'C',
    'KEY_D': u'D',
    'KEY_E': u'E',
    'KEY_F': u'F',
    'KEY_G': u'G',
    'KEY_H': u'H',
    'KEY_I': u'I',
    'KEY_J': u'J',
    'KEY_K': u'K',
    'KEY_L': u'L',
    'KEY_M': u'M',
    'KEY_N': u'N',
    'KEY_O': u'O',
    'KEY_P': u'P',
    'KEY_Q': u'Q',
    'KEY_R': u'R',
    'KEY_S': u'S',
    'KEY_T': u'T',
    'KEY_U': u'U',
    'KEY_V': u'V',
    'KEY_W': u'W',
    'KEY_X': u'X',
    'KEY_Y': u'Y',
    'KEY_Z': u'Z',
    'KEY_TAB': u'\t',
    'KEY_SPACE': u' ',
    'KEY_COMMA': u',',
    'KEY_SEMICOLON': u';',
    'KEY_EQUAL': u'=',
    'KEY_LEFTBRACE': u'[',
    'KEY_RIGHTBRACE': u']',
    'KEY_MINUS': u'-',
    'KEY_APOSTROPHE': u'\'',
    'KEY_GRAVE': u'`',
    'KEY_DOT': u'.',
    'KEY_SLASH': u'/',
    'KEY_BACKSLASH': u'\\',
    'KEY_ENTER': u'\n',
    'KEY_LEFTSHIFT': u'',
}


def localInfo():
    local_ip = list()
    local_mac = list()
    for interface in netifaces.interfaces():
        try:
            mac = netifaces.ifaddresses(interface)[netifaces.AF_LINK][0]['addr']
            ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
            if ip is not None and mac is not None and ip != '127.0.0.1' and ip != '' and mac != '':
                print(mac, ip)
                local_mac.append(mac)
                local_ip.append(ip)
        except KeyError:
            pass
        # if interface == routingNicName:
        #     try:
        #
        #         local_ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']  # 获取IP
        #     except KeyError:
        #         pass
    return local_ip, local_mac
